<?php
  header("Content-type:text/html;charset=utf-8");
  $name = $_POST["userName"];
  $pwd = $_POST["userPwd"];
  
  $conn = mysql_connect("localhost","root","root");
  mysql_select_db("database_phone");

  $result = mysql_query("select * from users where username='$name'",$conn);
  if(mysql_num_rows($result) == 1){
    echo "1";
  }else{
    mysql_query("insert into vmall values ('$name','$pwd')", $conn);
    $result1 = mysql_query("select * from users where username='$name'", $conn); 
    $row = mysql_fetch_assoc($result1);
    echo $row["id"];
  }
  
  

  mysql_close($conn);
?>
